﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Xml.Linq;

namespace devtm.Editor.Configuration.Merge
{

    public enum Enumside
    {
        Left = 0,
        Right
    }

    public class Diff
    {
        public ElementSection ElementSection { get; set; }
        public ConfigurationSection Section { get; set; }
        public Enumside Side { get; set; }

        private string _text;

        public string Text
        {
            get 
            {
                return _text; 
            }
        }

        private Diff(Enumside side)
        {
            Side = side;
        }

        public Diff(Configuration.ElementSection elementSection, Enumside side) : this(side)
        {
            if (elementSection != null)
            {
                this.ElementSection = elementSection;
                _text = elementSection.RawXml.ToString(System.Xml.Linq.SaveOptions.OmitDuplicateNamespaces);
            }

        }

        public Diff(ConfigurationSection section, Enumside side) : this(side)
        {
            if (section != null)
            {
                this.Section = section;
                _text = section.SectionInformation.GetRawXml();
                if (!string.IsNullOrEmpty(_text))
                    _text = XElement.Parse(_text).ToString(System.Xml.Linq.SaveOptions.OmitDuplicateNamespaces);
            }
        }

    }

}
